package inventory.view;

import inventory.master.view.MasterManagementMainView;
import inventory.reports.view.ReportsMainView;
import inventory.stockManagement.view.StockManagementMainView;

import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.SpringLayout;
import javax.swing.border.LineBorder;

import viewframework.UIFrameWork;

public class InventoryMainView  extends JPanel implements MouseListener
{
	private SpringLayout springLayout;
	private JSeparator separatorHeader;
	private JSeparator separatorFooter;
	private JLabel[] headerMenu;
	private String[] labelNames;

	public InventoryMainView()
	{
		setForeground(Color.WHITE);
		setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		setBackground(Color.WHITE);
		springLayout = new SpringLayout();
		setLayout(springLayout);
		
		separatorHeader = new JSeparator();
		separatorHeader.setForeground(Color.PINK);
		springLayout.putConstraint(SpringLayout.NORTH, separatorHeader, 100, SpringLayout.NORTH,this);
		springLayout.putConstraint(SpringLayout.WEST, separatorHeader, 0, SpringLayout.WEST,this);
		springLayout.putConstraint(SpringLayout.EAST, separatorHeader, 0, SpringLayout.EAST,this);
		add(separatorHeader);
		//*************************************************************************************
		separatorFooter = new JSeparator();
		springLayout.putConstraint(SpringLayout.SOUTH, separatorFooter, -30, SpringLayout.SOUTH,this);
		springLayout.putConstraint(SpringLayout.WEST, separatorFooter, 0, SpringLayout.WEST,this);
		springLayout.putConstraint(SpringLayout.EAST, separatorFooter, 0, SpringLayout.EAST,this);
		add(separatorFooter);
		//*************************************************************************************
		labelNames=new String[]{"Home","Master Management","Stock Management","Reports"};
		
		Dimension[]preferedSize={new Dimension(70, 30),new Dimension(190, 30),new Dimension(180, 30),new Dimension(100, 30)};
		headerMenu=UIFrameWork.makeHeaderMenu(this, labelNames,50,2,0,preferedSize);
		
		Font font=new Font("MS Reference Sans Serif", Font.BOLD, 13);
		LineBorder border=new LineBorder(Color.PINK, 1, true);
		UIFrameWork.headerMenuStyling(headerMenu,Cursor.HAND_CURSOR,Color.WHITE, border,Color.PINK, font);
		
		UIFrameWork.addListeners(headerMenu,this);
	}

	@Override
	public void mouseClicked(MouseEvent arg0) 
	{
		JLabel label=(JLabel) arg0.getSource();
		String title=label.getText();
		
		if(title.equals("Home"))
		{
			UIFrameWork.stickPanel(this,new JPanel(),7);
		}
		
		if(title.equals("Master Management"))
		{
			MasterManagementMainView mmmv=new MasterManagementMainView();
			UIFrameWork.stickPanel(this,mmmv,7);
		}
		
		if(title.equals("Stock Management"))
		{
			StockManagementMainView smmv=new StockManagementMainView();
			UIFrameWork.stickPanel(this,smmv,7);
		}
		
		if(title.equals("Reports"))
		{
			ReportsMainView rmv=new ReportsMainView();
			UIFrameWork.stickPanel(this,rmv,7);
		}
		
	}
	
	

	@Override
	public void mouseEntered(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseExited(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mousePressed(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}
}
